-------------------------------------------------------------------------------
--  The Legend of Zelda : Oracle of Secrets
--  Copyright (C) 2010 Pixelua
--
--  This program is free software: you can redistribute it and/or modify
--  it under the terms of the GNU General Public License as published by
--  the Free Software Foundation, either version 3 of the License, or
--  (at your option) any later version.
--
--  This program is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------------

map_access_tab = {a1, a2}

function mapaccess(actual_map_tab, dir, nxtmap)
	if dir == 1 then
		nextmap = actual_map_tab.down
		save["save"]["x"] = link.casex
		save["save"]["y"] = tostring(0)
	elseif dir == 2 then
		nextmap = actual_map_tab.right
		save["save"]["x"] = tostring(0)
		save["save"]["y"] = link.casey
	elseif dir == 3 then
		nextmap = actual_map_tab.left
		save["save"]["x"] = tostring(15)
		save["save"]["y"] = link.casey
	elseif dir == 4 then
		nextmap = actual_map_tab.up
		save["save"]["x"] = link.casex
		save["save"]["y"] = tostring(11)
	end
	
	save["save"]["map"] = tostring(nextmap)
	save["save"]["dir"] = tostring(link.direction)
	INI.save("saves/save.ini",save)
	
	mapchange = true
end
